package com.group10.mapper;

import com.group10.entity.Result;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

@Component
public interface LikeMapper {

    @Insert("insert into likes(topic,user_id,like_id,time) value(#{topic},#{userId},#{likeId},#{time})")
    int insertLike(String topic, String userId, Integer likeId,String time);

    @Select("select count(*) from likes where topic=#{topic} and user_id=#{userId} and like_id=#{likeId}")
    int isLike(String topic,String userId,Integer likeId);

    @Select("select count(*) from likes where topic=#{topic} and like_id=#{likeId}")
    int getCount(String topic,Integer likeId);

    @Delete("delete from likes where topic=#{topic} and user_id=#{userId} and like_id=#{likeId}")
    int deleteLike(String topic,String userId,Integer likeId);
}
